package com.nintendo.controller;

import com.nintendo.entity.Test;
import com.nintendo.response.Result;
import com.nintendo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hello")
public class TestController {
    @Autowired
    private TestService testService;
    @RequestMapping("/hello")
    public String hello(){
        return "hello";
    }
    @PostMapping("/hello")
    public String hello2(String name){
        return "hello" +name;
    }
    @PutMapping("/hello")
    public String hello3(String name){
        return name;
    }
    @RequestMapping("/hello4")
    public Map<String,Object> hello7(String name){
        return Map.of("name",name);
    }
    @GetMapping("/test")
    public Result findAllTest() {
        List<Test> list = testService.list();
        Map<String,Object> map = new HashMap<>();
        map.put("list",list);
        return Result.ok(map);
    }
}
